﻿@model System.Web.Security.MembershipUserCollection

@{
    ViewBag.Title = "SGC - Usuarios";
}
<script type="text/javascript" language="Javascript">
    function obtenerValorRadio() {
        radioGroup = document.forms["RadioButtonForm"].RadioButtonCategorias;
        respuesta = document.forms["RadioButtonForm"].RadioButtonCategorias.value;
        for (var i = 0; i < radioGroup.length; i++) {
            if (radioGroup[i].checked) {
                respuesta = radioGroup[i].value;
            }
        }
        return respuesta;
    }
    function eliminarUsuarios() {
        x = obtenerValorRadio();
        document.location = "/Membership/Delete/" + x;
    }

    function editarUsuarios() {
        x = obtenerValorRadio();
        document.location = "/Membership/Edit/" + x;
    }
    </script>

    <div style="width:100%; float:left">
    <h3 style="float:left">Usuarios</h3>
    <div style="float:right">
    @Html.ActionLink("Inicio", "Index", "Home")
    @Html.ActionLink("Volver", "Admin", "Mail")</div>
</div>
<hr />

<!-- Inicio busqueda de texto --><div style="width: 100%; float:left">
        @using (Html.BeginForm())
        {
            <p style="float:right">
            Buscar: <input type="text" value="@ViewBag.S" name="s" />
            <input type="submit" value="Buscar" />
            </p>
        }
    <!-- Fin busqueda de texto --></div>

<table id="opcionesManager" class="opcionesManagerTable" style="width:100%">
        <tr>
            <td class="opcionesManagerTd">
                <div id="fontTitulo" >Usuarios</div>
            </td>    
            <td  style="width:280px"></td>
            <td class="opcionesManagerTd">
                <a href= "@Url.Action("Create", "Membership")"><img src="../../Content/icons/001_01.png" alt="Crear" width="20" height="20" align="middle"/></a>
            </td>
            <td class="opcionesManagerTdLetra">
                <a href="@Url.Action("Create", "Membership")" class="sortColumn">Nuevo</a>
            </td>            
            <td class="opcionesManagerTd">
                <a onclick="editarUsuarios()" href="#" class="sortColumn" ><img src="../../Content/icons/001_45.png" alt="Editar" width="20" height="20" align="middle"/></a>
            </td>
            <td class="opcionesManagerTdLetra">
                <a onclick="editarUsuarios()" href="#" class="sortColumn" >Editar</a>
            </td>                        
            <td class="opcionesManagerTd">
                <a onclick="eliminarUsuarios()" href="#" ><img src="../../Content/icons/001_29.png" alt="Editar" width="20" height="20" /></a>
            </td>
            <td class="opcionesManagerTdLetra">
                <a onclick="eliminarUsuarios()" href="#" class="sortColumn" >Eliminar</a>
            </td>
        </tr>        
</table>
<br /><br />
<form id="RadioButtonForm" action="">
    <table style="width:100%" class="opcionesManagerTable" border="1" cellspacing="0" cellpadding="0">
        <tr>
            <th>#</th>
            <th>
                Nombre de usuario
            </th>
            <th>
                Email
            </th>
            <th>
                Último Login
            </th>
            <th>
                Descripción
            </th>
        </tr>    

    @foreach (MembershipUser item in Model) { 
    
        <tr>
            <td class="listas">
                @Html.RadioButton("RadioButtonCategorias",item.ProviderUserKey,true, new { id="RadioButtonCategorias", runat="server"})
            </td>
            <td  class="listas" style="min-width:100px">
                @Html.ActionLink(item.UserName, "Detail", new { id = (Guid)item.ProviderUserKey })
            </td>
            <td  class="listas" style="min-width:300px">
                @Html.Encode(item.Email)
            </td>
            <td  class="listas" style="min-width:100px">
                @Html.Encode(String.Format("{0:d}", item.LastLoginDate))
            </td>
            <td  class="listas" style="width:100%">
                @Html.Encode(item.Comment)
            </td>
        </tr>
    
    }
    </table>

 </form>
 <div>
@if (ViewBag.cont == 0)
{
    <text><strong> No se ha obtenido ningún resultado, para recargar presione @Html.ActionLink("aquí","Index") </strong> </text> 
}
</div>
    @if (ViewBag.Paginacion == true)
    {
        <div>
    Página @(ViewBag.PageCount < ViewBag.PageNumber ? 0 : ViewBag.PageNumber+1)
    de @ViewBag.PageCount
     
    @if (ViewBag.HasPreviousPage)
    {
        @Html.ActionLink("<<", "Index", new { page = 1 })
        @Html.Raw(" ");
        @Html.ActionLink("< Ant", "Index", new { page = ViewBag.PageNumber - 1 })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Ant
    }
     
    @if (ViewBag.HasNextPage)
    {
        @Html.ActionLink("Sgt >", "Index", new { page = ViewBag.PageNumber + 1 })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "Index", new { page = ViewBag.PageCount })
    }
    else
    {
        @:Sgt >
        @Html.Raw(" ")
        @:>>
    }
</div>
    }
